//
//  OrderCell.m
//  phmall
//
//  Created by admin on 2017/10/6.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "OrderCell.h"

@implementation OrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    OrderCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[OrderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    cell.backgroundColor=[UIColor clearColor];
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.back=[[UIView alloc]init];
        self.back.backgroundColor=[UIColor whiteColor];
        [self.contentView addSubview:self.back];
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.goodsImg=[[UIImageView alloc]init];
        self.goodsImg.image =[UIImage imageNamed:@"图片"];
        ViewBorderRadius(self.goodsImg, 5, 0, [UIColor whiteColor]);
        [self.contentView addSubview: self.goodsImg];
        
        self.name=[[UILabel alloc]init];
        self.name.text=@"ROSIE FOR AUTOGRAPH 丝绸和蕾丝拼接Beau Plunge胸罩AE";
        self.name.font=[UIFont systemFontOfSize:13];
        self.name.numberOfLines=2;
        [self.contentView addSubview:self.name];
        
        self.specification=[[UILabel alloc]init];
        self.specification.text=@"尺码:36D/E罩杯";
//        self.specification.numberOfLines=2;
        self.specification.font=[UIFont systemFontOfSize:11];
        self.specification.textColor=[UIColor colorWithHexString:@"#BFC3C4"];
        [self.contentView addSubview:self.specification];
        
        self.number=[[UILabel alloc]init];
        self.number.text=@"*5";
        self.number.font=[UIFont systemFontOfSize:13];
        self.number.textColor=[UIColor colorWithHexString:@"#BFC3C4"];
        [self.contentView addSubview:self.number];
        
        self.price=[[UILabel alloc]init];
        self.price.text=@"₱8888.00";
        self.price.textColor=[UIColor colorWithHexString:@"#BFC3C4"];
        self.price.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.price];
        
        self.market_price=[[UILabel alloc]init];
        self.market_price.text=@"₱8888.00";
        self.market_price.textColor=[UIColor orangeColor];
        self.market_price.font=[UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.market_price];
        
        self.line=[UIView new];
        self.line.backgroundColor=[UIColor groupTableViewBackgroundColor];
        [self.contentView  addSubview:self.line];
      
        
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    
    [self.back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(2);
        make.bottom.equalTo(self.contentView).offset(-2);
    }];
    
    [self.goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.back).offset(10);
        make.bottom.equalTo(self.back).offset(-10);
        make.width.mas_equalTo(self.goodsImg.mas_height);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.goodsImg).offset(0);
        make.left.equalTo(self.goodsImg.mas_right).offset(10);
        make.right.equalTo(self.back).offset(-10);
    }];
    
    [self.specification mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.market_price.mas_top).offset(-7);
        make.left.equalTo(self.name);
    }];
    
    [self.number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.back).offset(-10);
        make.centerY.equalTo(self);
    }];
    
    [self.market_price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.name);
        make.bottom.equalTo(self.goodsImg.mas_bottom);
    }];
    
    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.market_price.mas_right).offset(5);
        make.bottom.equalTo(self.market_price).offset(-0.5);
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.left.right.offset(0);
        make.height.mas_equalTo(1);
    }];
}
-(void)setModel:(GoodsListModel *)model{
    _model=model;
    [self.goodsImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@union/%@",IMGURL,model.goods_file]] placeholderImage:[UIImage imageNamed:@"图片空白页"]];
    self.name.text=model.goods_name;
    self.market_price.text=[NSString stringWithFormat:@"₱%@",model.buy_price];
    if (model.rest_price==nil||[model.rest_price isEqualToString:@"0"]) {
        self.price.hidden=YES;
    }
    self.price.text=[NSString stringWithFormat:@"₱%@",model.rest_price];
    [self.price setLabelWithDelLine];
    
    self.specification.text=model.goods_attr;
    self.number.text=[NSString stringWithFormat:@"*%@",model.buy_number];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
